#include "EEGDataRelay.h"

EEGDataRelay::EEGDataRelay(ConfigImport *sys_config, QObject *parent):
    QObject(parent),
    sys_config(sys_config)
{
    sendPointNum = sys_config->pointPerTrial;
    sim_accumulateNum = 0;
    sim_rec_buff.clear();
    
}

EEGDataRelay::~EEGDataRelay()
{
    
}

/**********************************
 * 函数名：receiveData
 * 功能：接收放大器数据，进行中转
 * 输入：放大器发送的数据
 * 输出：无
 * 备注：无
**********************************/
void EEGDataRelay::receiveData(const std::vector <EEG_VOLTAGE>& eegData){
    printf("in eeg_Dev\n");
    

}


// 仿真设备
void EEGDataRelay::receiveData(const arma::fcube& eegData){
    arma::cube tempData = arma::conv_to<arma::cube>::from(eegData);
    static bool flag = 0;
    if(!flag){
        flag = 1;
        sim_rec_buff = tempData;
        return;
    }
    sim_rec_buff.insert_slices(sim_rec_buff.n_slices, arma::conv_to<arma::cube>::from(eegData));
    if(sim_rec_buff.n_slices >= sendPointNum){
        emit dataPrepared(sim_rec_buff);
        // printf("len = %lld\n",sim_rec_buff.n_slices);
        sim_rec_buff.clear();
        flag = 0;
    }

    #ifdef DEBUG
    printf("tempData len = %lld\n",tempData.n_slices);
    printf("len = %lld\n",sim_rec_buff.n_slices);
    #endif // DEBUG

}